package org.systemsbiology.bigquery.gae.servlets;

import com.google.api.client.sample.bigquery.appengine.dashboard.AuthServlet;
import com.google.api.client.sample.bigquery.appengine.dashboard.AuthUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

import static com.google.appengine.api.memcache.MemcacheServiceFactory.getMemcacheService;
import static org.apache.commons.lang.StringUtils.equalsIgnoreCase;

/**
 * @author hrovira
 */
public class AdminRefreshOAuth2Servlet extends AuthServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        AuthUtils authUtils = new AuthUtils(getUserId(), getHttpTransport(), getJsonFactory());
        authUtils.refreshAccessToken();

        getMemcacheService("queries").clearAll();
    }

}
